package com.javabean;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Orders {
  private int id;
  private String orderNum;
  @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
  private Date orderTime;
  private int peopleCount;
  private String orderDesc;
  private int payType;//'支付方式（0 支付宝 1微信 2 其他',
  private int orderStatus;// '订单状态（0未支付1已支付）',
  private int productId;// '产品id外键',
  private int memberId;// '会员（联系人）id外键'
  private Product product;
  private Member member;
  private ArrayList<Traveller> travellers;



  private String departureTimeStr;

  public String getorderTimeStr() {
    // 对日期格式化
    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    if (null != orderTime) {
      departureTimeStr = dateFormat.format(orderTime);
    }
    return departureTimeStr;
  }

  public String getPayTypeStr() {
    String payTypeStr="";
    if (payType == 0){
      payTypeStr = "支付宝";
    } else if(payType == 1){
      payTypeStr = "微信";
    }else if(payType == 2){
      payTypeStr = "其他";
    }
    return payTypeStr;
  }

  public String getOrderStatusStr() {
    String orderStatusStr="";
    if (orderStatus == 0){
      orderStatusStr = "未支付";
    } else if(orderStatus == 1){
      orderStatusStr = "已支付";
    }
    return orderStatusStr;
  }
}